#include "s3c2440_soc.h"

void delay(volatile int cnt)
{
	while(cnt--);
}

int main()
{
	/* 先将对应的位清零 */
	GPFCON &= ~((3<<8) | (3<<10) |(3<<12));

	/* 再将对应的位标记为输出引脚 */
	GPFCON |= ((1<<8) | (1<<10) | (1<<12));


	/* 按键管脚GPF0=EINT0; GPF2=EINT2; GPG3=EINT11; */
	/* 将对应的管脚作为输入管脚 0x00	 */
	GPFCON &= ~((3<<0) | (3<<4));
	GPGCON &= ~(3<<6); 

	/* 然后监听该地址的值来判断按键是否按下 */

	int gpf_dat = 0;
	int gpg_dat = 0;
	/* 循环点亮 */
	while(1)
	{
		gpf_dat = GPFDAT;
		gpg_dat = GPGDAT;

		/* 按键EINT0->LED4 D12->GPF6 */
		if (gpf_dat & (1<<0)) {
			/* 高电频,说明是松开状态 */
			GPFDAT |= (1<<6);
		}else{
			GPFDAT &= ~(1<<6);
		}

		/* 按键EINT2->LED2 D11->GPF5 */
		if (gpf_dat & (1<<2)) {
			GPFDAT |= (1<<5);
		}else{
			GPFDAT &= ~(1<<5);
		}

		/* 按键EINT11->LED1 D10->GPF4 */
		if (gpg_dat & (1<<3)) {
			GPFDAT |= (1<<4);
		}else{
			GPFDAT &= ~(1<<4);
		}
	}
	return 0;
}
